﻿using dotnet_graphql_demo.Model;
using HotChocolate;
using HotChocolate.Execution;
using HotChocolate.Subscriptions;
using HotChocolate.Types;
using System.Threading;
using System.Threading.Tasks;

namespace dotnet_graphql_demo.Infrastructure.Graphql
{
    public class OwnerSubscription
    {
        [SubscribeAndResolve]
        public async ValueTask<ISourceStream<Owner>>OnAuthorCreated([Service]ITopicEventReceiver eventReceiver, CancellationToken cancellationToken)
        {
            return await eventReceiver.SubscribeAsync<string, Owner>("OwnerCreated", cancellationToken);
        }
    }
}
